package com.example.demo3.controller;


import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @GetMapping(path = "/hello")
    public String hello(){
        String ms  = "hello123123";
        System.out.println(ms);
        return ms;
    }

    private final ChatClient chatClient;

    public DemoController(ChatClient.Builder builder) {
        this.chatClient = builder.build();
    }

    @GetMapping("/chat")
    public String chat(@RequestParam(value = "input") String input) {
        String content = this.chatClient.prompt()
                .user(input)
                .call()
                .content();
        System.out.println(content);
        return content;
    }
}
